﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style type="text/css">
        body, html {
            width: 100%;
            height: 100%;
            margin: 0;
            font-family: "微软雅黑";
            font-size: 14px;
        }

        #container {
            height: 700px;
            width: 100%;
        }

        #r-result {
            width: 100%;
        }
    </style>
    <script type="text/javascript" src="//api.map.baidu.com/api?type=webgl&v=1.0&ak=E6fLfoZvafshmZ0srkPPo9Iu2f8xOZHa"></script>
    <script src="~/libs/jquery/jquery.js"></script>
    <link href="~/layui/css/layui.css" rel="stylesheet" />
    <title>根据起点和终点规划路线</title>
</head>
<body>
    <a class="layui-btn " onclick="location.href='/CargoownerTrack/Index'">返回</a>
    @*<div id='result'>根据起点和终点规划路线</div>
    <div class="searchDiv" style="padding:15px 0 15px 0;">
        起点：<input id="bcity" value="北京市" />-  终点：<input id="ecity" value="雄安新区" />
        <input type="button" value="查询" id="search" />
    </div>*@
    <div id="container" ></div>
    <script>
        $(function () {
            setmap();
            $("#search").click(function () {
                setmap();
            });
        });

        function theLocation() {
            var bcity = document.getElementById("bcity").value;
            if (bcity != "") {
                map.centerAndZoom(bcity, 11);      // 用城市名设置地图起点
            }
            var ecity = document.getElementById("ecity").value;
            if (ecity != "") {
                map.centerAndZoom(ecity, 11);      // 用城市名设置地图终点
            }
        }

        function setmap() {
            //var bcity = document.getElementById("bcity").value;
            //var ecity = document.getElementById("ecity").value;
            $.ajax({
                url:"/CargoownerTrack/GetLine?Id="+@ViewBag.Id,
                type:"get",
                dataType:"json",
                async:false,
                success:function(obj){
                    bcity=obj.ldetail;
                    ecity=obj.ldestination;
                }
            })
            var map = new BMapGL.Map("container");
            map.enableScrollWheelZoom();
            map.centerAndZoom(new BMapGL.Point(116.404, 39.915), 11);
            var walking = new BMapGL.WalkingRoute(map, { renderOptions: { map: map, autoViewport: true } });
            //walking.search('西单', '慈云寺');
            //var bcity = document.getElementById("bcity").value;
            //var ecity = document.getElementById("ecity").value;
            walking.search(bcity, ecity);
        }
    </script>
</body>
</html>


